package com.tj.jinzao.presenter;


import android.util.Log;

import com.tj.jinzao.api.SubscriberCallBack;
import com.tj.jinzao.base.BasePresenter;
import com.tj.jinzao.callback.LiveView;
import com.tj.jinzao.model.LiveBean;
import com.tj.jinzao.model.ResultResponse;

import java.util.HashMap;
import java.util.List;

/**
 * 日记，文章列表处理
 * Created by wjy 2018/12/10.
 */
public class LivePresenter extends BasePresenter<LiveView<List<LiveBean>>> {

    public LivePresenter(LiveView<List<LiveBean>> view) {
        super(view);
    }

    public void getLiveList(HashMap<String,Object> hashMap) {
        Log.w("数据接收","请求"+hashMap.toString());
        addSubscription(mApiService.getLive(hashMap), new SubscriberCallBack<List<LiveBean>>(mView.getContext()) {
            @Override
            protected void onSuccess(List<LiveBean> list) {
                Log.w("数据接收","qqqqzqq"+list.toString());
                if (mView != null) mView.onRequestSuccess(list);
            }

            @Override
            protected void onFailure(ResultResponse response) {
                if (mView != null) mView.onRequestError(response.getMessage());
            }

            @Override
            protected boolean isShowProgress() {
                return false;
            }

            @Override
            protected void onPageSuccess(int currentPage, int allPage, int allSize) {
                if (mView != null) mView.onRequestSuccessPage(currentPage, allPage, allSize);
            }
        });

    }
    public void getRecomedList(HashMap<String,Object> hashMap) {
        addSubscription(mApiService.getRecomedList(hashMap), new SubscriberCallBack<List<LiveBean>>(mView.getContext()) {
            @Override
            protected void onSuccess(List<LiveBean> list) {
                if (mView != null) mView.onRequestSuccess(list);
            }

            @Override
            protected void onFailure(ResultResponse response) {
                if (mView != null) mView.onRequestError(response.getMessage());
            }

            @Override
            protected boolean isShowProgress() {
                return false;
            }

            @Override
            protected void onPageSuccess(int currentPage, int allPage, int allSize) {
                if (mView != null) mView.onRequestSuccessPage(currentPage, allPage, allSize);
            }
        });

    }
    public void goLive(HashMap<String,Object> hashMap) {
        Log.w("数据接收请求",hashMap.toString());
        addSubscription(mApiService.goLive(hashMap), new SubscriberCallBack<LiveBean>(mView.getContext()) {
            @Override
            protected void onSuccess(LiveBean list) {
                if (mView != null) mView.goLiveSuccess(list);
            }

            @Override
            protected void onFailure(ResultResponse response) {
                if (mView != null) mView.goLiveFailed(response.getMessage());
            }
        });

    }
}